package block

import (
	"blockchaingo/wallet"
	"bytes"
)

type TxInput struct {
	TxId      []byte //交易哈希
	Vout      int    //输出值
	Signature []byte //签名
	PubKey    []byte //公钥
}

//检查输入是否使用特定的键来解锁输出
func (in *TxInput) UseKey(pubKeyHash []byte) bool {
	lockingHash := wallet.HashPubKey(in.PubKey)
	return bytes.Compare(lockingHash, pubKeyHash) == 0
}
